<div class="pageContent">
	<form method="post" action="admin.php?mod=user_role&action=edit" class="pageForm required-validate" onsubmit="return validateCallback(this, ddialogAjaxDone);">
        <input type="hidden" name="is_submit" value="1"/>
        <div class="pageFormContent" layoutH="97">
            <p>
                <label>{lang user_role_name}</label>
                <input type="hidden" name="role_id" value="{$role_result['role_id']}" />
                <input name="role_name" class="textInput required" type="text" size="30" value="{$role_result['role_name']}" alt="{lang please_input}{lang user_role_name}" />
            </p>
            <p>
                <label>{lang role_menu_access}</label>
                <input type="hidden" id="user_role_menu" name="user_role_menu" value="{$role_result['user_role_menu']}" />
                <div id="resultBox"></div>
                <div style="float:left; display:block; margin:10px; overflow:auto; width:500px; height:200px; overflow:auto; border:solid 1px #CCC; line-height:21px; background:#FFF;">
                    <SCRIPT type="text/javascript">
                        <!--
                        var setting = {
                            view: {
                                selectedMulti: false
                            },
                            check: {
                                enable: true
                            },
                            data: {
                                simpleData: {
                                    enable: true
                                }
                            },
                            callback: {
                                beforeCheck: beforeCheck,
                                onCheck: onCheck
                            }
                        };

                        var zNodes ={$menu_json_string};

                        var code, log, className = "dark";
                        function beforeCheck(treeId, treeNode) {
                            className = (className === "dark" ? "":"dark");
                            return (treeNode.doCheck !== false);
                        }
                        
                        function onCheck(e, treeId, treeNode) {
                            var user_role_menu_nodes_str = '';
                            var user_role_menu_obj = $.fn.zTree.getZTreeObj("user_role_menu_tree");
                            var user_role_menu_obj_checked_nodes = user_role_menu_obj.getCheckedNodes(true);
                            for (var i=0, l=user_role_menu_obj_checked_nodes.length; i<l; i++) {
                                user_role_menu_nodes_str = user_role_menu_nodes_str + ',' + user_role_menu_obj_checked_nodes[i]["id"];
                            }
                            $("#user_role_menu").val(user_role_menu_nodes_str);
                        }

                        function setAutoTrigger(e) {
                            var zTree = $.fn.zTree.getZTreeObj("user_role_menu_tree");
                            zTree.setting.check.autoCheckTrigger = $("#autoCallbackTrigger").attr("checked");
                            $("#autoCheckTriggerValue").html(zTree.setting.check.autoCheckTrigger ? "true" : "false");
                        }

                        $(document).ready(function(){
                            $.fn.zTree.init($("#user_role_menu_tree"), setting, zNodes);
                            $("#autoCallbackTrigger").bind("change", {}, setAutoTrigger);
                        });
                        //-->
                    </SCRIPT>
                    <ul id="user_role_menu_tree" class="ztree"></ul>
                </div>
            </p>
        </div>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">{lang save}</button></div></div></li>
				<li><div class="button"><div class="buttonContent"><button type="button" class="close">{lang cancel}</button></div></div></li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
function kkk(){
	var json = arguments[0], result="";
//	alert(json.checked);

	$(json.items).each(function(i){
		result += "<p>name:"+this.name + " value:"+this.value+" text: "+this.text+"</p>";
	});
	$("#resultBox").html(result);
	
}
</script>